﻿<?xml version="1.0" encoding="utf-8" ?>
<ViewModelMapping xmlns="urn:mvmmapper:mappingfile">
  <ViewModelClass name="Person"
                  namespace="PersonLookup.ViewModel"
                  implementIEditableObject="true"
                  commandClass="MVVM.ActionCommand"
                  collectionClassName="PersonCollection"
                  modelClass="PersonLookup.PersonServiceReference.Person">
    <Properties>

      <Property name="ID"
                type="int">
        <ModelMapping propertyPath="ID"/>
      </Property>

      <Property name="FirstName"
                type="string">
        <ModelMapping propertyPath="FirstName"/>
      </Property>

      <Property name="LastName"
                type="string">
        <ModelMapping propertyPath="LastName"/>
      </Property>

      <Property name="EntityStatus"
                type="MVVM.EntityStatus"/>

    </Properties>
    
  </ViewModelClass>
  
  <ViewModelProviderClass name="PersonProvider"
                          namespace="PersonLookup.ViewModel.Providers">
    <Methods>
      <Method name="Save"
              generateCommand="true">
        <Result name="person"
                type="PersonLookup.ViewModel.Person"
                isViewModel="true"/>
        <Parameter name="person"
                   type="PersonLookup.ViewModel.Person"
                   isViewModel="true"/>
        <WrappedMethod name="AddPersonAsync"
                       providerName="PersonServiceClient"
                       providerNamespace="PersonLookup.PersonServiceReference">
          <Result>
            <Asynchronous methodCompletedEventName="AddPersonCompleted"
                          eventArgsType="PersonLookup.PersonServiceReference.AddPersonCompletedEventArgs"/>
          </Result>
        </WrappedMethod>
      </Method>

      <Method name="Update"
              generateCommand="true">
        <Result name="rowsAffected"
                type="int"/>
        <Parameter name="person"
                   type="PersonLookup.ViewModel.Person"
                   isViewModel="true"/>
        <WrappedMethod name="UpdatePersonAsync"
                       providerName="PersonServiceClient"
                       providerNamespace="PersonLookup.PersonServiceReference">
          <Result>
            <Asynchronous methodCompletedEventName="UpdatePersonCompleted"
                          eventArgsType="PersonLookup.PersonServiceReference.UpdatePersonCompletedEventArgs"/>
          </Result>
        </WrappedMethod>
      </Method>

      <Method name="Delete"
              generateCommand="true">
        <Result name="rowsAffected"
                type="int"/>
        <Parameter name="person"
                   type="PersonLookup.ViewModel.Person"
                   isViewModel="true"/>
        <WrappedMethod name="DeletePersonAsync"
                       providerName="PersonServiceClient"
                       providerNamespace="PersonLookup.PersonServiceReference">
          <Result>
            <Asynchronous methodCompletedEventName="DeletePersonCompleted"
                          eventArgsType="PersonLookup.PersonServiceReference.DeletePersonCompletedEventArgs"/>
          </Result>
        </WrappedMethod>
      </Method>
      
    </Methods>
  </ViewModelProviderClass>
</ViewModelMapping>